<script type="text/javascript">
  $(document).ready(function() {
    expand_group();
  });
</script>
<div class="page" style="min-height: 500px;">
  <div class="page-container">
    <div class="container">
      <div class="row">
        <div class="span3">
          <h4 class="header">Groups</h4>
          <div class="sidebar">
            <ul class="col-nav span3">
              <li><a href="<?php echo base_url('groups/group_list/' . $selected_year); ?>"><i class="pull-right icon-cog"></i>Group list</a></li>
              <li style="background-color: #EEE;"><a href="<?php echo base_url('groups/group_members/' . $selected_year); ?>"><i class="pull-right icon-user"></i>Group members</a></li>
              <li><a href="<?php echo base_url('groups/group_events/' . $selected_year); ?>"><i class="pull-right icon-star"></i>Group events</a></li>
            </ul>
          </div>
        </div>
        <div class="span9">
          <div class="btn-group pull-right">
            <?php if ($this->is_comitte_member) { ?>
              <a title="<?php echo 'Can accessed by : @' . @implode(', @', $this->comitte_members); ?>" href="<?php echo base_url('groups_manage'); ?>" class="btn">Manage groups</a>
            <?php } ?>
            <button class="btn dropdown-toggle" data-toggle="dropdown"><i class="icon-calendar"></i>&nbsp;<?php echo $selected_year; ?>&nbsp;<span class="caret"></span></button>
            <ul class="dropdown-menu">
              <?php if (!empty($group_years)) { ?>
                <?php foreach ($group_years as $group_year) { ?>
                  <li>
                    <a href="<?php echo site_url('groups/group_list/' . $group_year['group_years']); ?>"><?php echo $group_year['group_years']; ?></a>
                  </li>
                <?php } ?>
              <?php } ?>
            </ul>
          </div>
          <h4 class="header">Group members : <?php echo $selected_year; ?></h4>

          <?php if (!empty($groups)) { ?>

            <div class="sidebar">
              <ul class="col-nav span9">
                <?php foreach ($groups as $group) { ?>
                  <div id="G<?php echo $group['group_id']; ?>"></div>
                  <li style="background-color: #CCC;">
                    <a href="#group_<?php echo $group['group_id']; ?>" data-toggle="collapse" class="accordion-toggle" style="color: #515151; font-weight: bold;"><?php echo $group['group_name']; ?>&nbsp;(<?php echo count($group['group_members']); ?>)</a>
                  </li>
                  <?php if (!empty($group['group_members'])) { ?>
                    <li id="group_<?php echo $group['group_id']; ?>" class="collapse">
                      <ul>
                        <li>
                          <?php $mem_count = 1; ?>
                          <?php foreach ($group['group_members'] as $group_member) { ?>
                            <a href="<?php echo site_url('profile/' . $group_member['user_name']); ?>" style="color: #777; text-decoration: none; cursor: pointer;">
                              <?php echo $mem_count; ?>.
                              &nbsp;
                              <img style="height: 25px; width: 25px; max-height: 25px; max-width: 25px;" src="<?php echo base_url('assets/photos/' . $group_member['user_image']); ?>"/>
                              &nbsp;
                              <?php echo $group_member['user_display_name']; ?>
                              <span style="color: #777; font-size: smaller;">
                                (@<?php echo $group_member['user_name']; ?>)
                                <?php if ($group_member['user_id'] == $group['group_c_user_id']) { ?>
                                  &nbsp;<b>(Captain)</b>
                                <?php } ?>
                                <?php if ($group_member['user_id'] == $group['group_vc_user_id']) { ?>
                                  &nbsp;<b>(Vice Captain)</b>
                                <?php } ?>
                                <?php if ($group_member['user_id'] == $group['group_cm_user_id']) { ?>
                                  &nbsp;<b>(Comitte Member)</b>
                                <?php } ?>
                              </span>
                            </a>
                            <?php $mem_count++; ?>
                          <?php } ?>
                      </ul>
                    </li>
                  <?php } else { ?>
                    <li id="group_<?php echo $group['group_id']; ?>" class="collapse">
                      <ul>
                        <li>
                          <a style="color: #777;">No group members !</a>
                      </ul>
                    </li>
                  <?php } ?>
                <?php } ?>
              </ul>
            </div>
          <?php } else { ?>
            <div class="alert alert-danger">No groups !</div>
          <?php } ?>
        </div>
      </div>
    </div>
  </div>
</div>

